<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: MACAddress Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00130.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="#pub-static-attribs">Static Public Attributes</a> &#124;
<a href="#pri-attribs">Private Attributes</a> &#124;
<a href="#pri-static-attribs">Static Private Attributes</a>  </div>
  <div class="headertitle">
<div class="title">MACAddress Class Reference</div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="MACAddress" -->
<p><code>#include &lt;<a class="el" href="a00332_source.html">MACAddress.h</a>&gt;</code></p>
<div class="dynheader">
Collaboration diagram for MACAddress:</div>
<div class="dyncontent">
<div class="center"><img src="a00839.png" border="0" usemap="#MACAddress_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="a00840.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#a155b01d9d9c04fbe13ea9b821519b571">MACAddress</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#acd5a34c4730c3ce448d9d727bb693827">MACAddress</a> (uint64 bits)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#a46d88d3231c166f8f6305e181e62a02e">MACAddress</a> (const char *hexstr)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#a9ab1361f2773c6840f8fc96f73000b20">MACAddress</a> (const <a class="el" href="a00130.html">MACAddress</a> &amp;other)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00130.html">MACAddress</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#a81e0e779bcc372284a137c141eb14f3d">operator=</a> (const <a class="el" href="a00130.html">MACAddress</a> &amp;other)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#a5f94a6533e6b7854c43c0a562622156a">getAddressSize</a> () const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">unsigned char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#ac6db3e8b6dd37f0a93d89367fefb9d27">getAddressByte</a> (unsigned int k) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#a58b9995961b675dc92e06e769c01565c">setAddressByte</a> (unsigned int k, unsigned char addrbyte)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#a4e4d6d6314b17e0b7c76356db6b7e794">tryParse</a> (const char *hexstr)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#a8098d36b9f4a40ef61e1a3cb62cb27dd">setAddress</a> (const char *hexstr)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#aecea3ba50c9d01ec71c7bde14c71a9e4">getAddressBytes</a> (unsigned char *addrbytes) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a926e0823c90abbeb2f137999f6ed9851"></a><!-- doxytag: member="MACAddress::getAddressBytes" ref="a926e0823c90abbeb2f137999f6ed9851" args="(char *addrbytes) const " -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>getAddressBytes</b> (char *addrbytes) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#a6804ca5591fc6eeb256cc487805a0927">setAddressBytes</a> (unsigned char *addrbytes)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="acaa8ac5836c4aff98bb7ef6b7c3b047a"></a><!-- doxytag: member="MACAddress::setAddressBytes" ref="acaa8ac5836c4aff98bb7ef6b7c3b047a" args="(char *addrbytes)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>setAddressBytes</b> (char *addrbytes)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#a38c4ea471051c76e593f2c6b0340b1fe">setBroadcast</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#aa65a288ef8fe0e08e66912ffda5e3706">isBroadcast</a> () const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#aec80ce7ee8f529716e4b9354e93ca3c0">isMulticast</a> () const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#ae41af013d782b46483e7d0c84f0ed107">isUnspecified</a> () const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#a5eed6450abcdd795b2a3d59828a29802">str</a> () const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint64&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#a79f00509111e457048de0d6f5ae7aede">getInt</a> () const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#a2d1669ce517436105cd75faed677a303">equals</a> (const <a class="el" href="a00130.html">MACAddress</a> &amp;other) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#af52a8fbbad1c1d4fa4c4c4689911698d">operator==</a> (const <a class="el" href="a00130.html">MACAddress</a> &amp;other) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#a931bca85d72f853c0a5bda55edd85365">operator!=</a> (const <a class="el" href="a00130.html">MACAddress</a> &amp;other) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#a606bb3ec3982d81913c464c18f34db6f">compareTo</a> (const <a class="el" href="a00130.html">MACAddress</a> &amp;other) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00108.html">InterfaceToken</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#af646c7d6a3dbe4a94465fd3ec144f08f">formInterfaceIdentifier</a> () const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a65248517f7a54605e822d16f1b2622ef"></a><!-- doxytag: member="MACAddress::operator&lt;" ref="a65248517f7a54605e822d16f1b2622ef" args="(const MACAddress &amp;other) const " -->
bool&#160;</td><td class="memItemRight" valign="bottom"><b>operator&lt;</b> (const <a class="el" href="a00130.html">MACAddress</a> &amp;other) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a22b682545ec7ed5bad76b80405bb9d41"></a><!-- doxytag: member="MACAddress::operator&gt;" ref="a22b682545ec7ed5bad76b80405bb9d41" args="(const MACAddress &amp;other) const " -->
bool&#160;</td><td class="memItemRight" valign="bottom"><b>operator&gt;</b> (const <a class="el" href="a00130.html">MACAddress</a> &amp;other) const </td></tr>
<tr><td colspan="2"><h2><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static <a class="el" href="a00130.html">MACAddress</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#a020d8e71aa50506e2b29a15833fedfd9">generateAutoAddress</a> ()</td></tr>
<tr><td colspan="2"><h2><a name="pub-static-attribs"></a>
Static Public Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static const <a class="el" href="a00130.html">MACAddress</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#a9083fdb636ab09f77e7af806f2d471b6">UNSPECIFIED_ADDRESS</a></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static const <a class="el" href="a00130.html">MACAddress</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#a64288e3935e32fec17884c040cf2d2e9">BROADCAST_ADDRESS</a></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static const <a class="el" href="a00130.html">MACAddress</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html#ad7361315e8e61b3e5e1494c55cc4721f">MULTICAST_PAUSE_ADDRESS</a></td></tr>
<tr><td colspan="2"><h2><a name="pri-attribs"></a>
Private Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a0c29ad39890488e0f7bc4ee20624e04e"></a><!-- doxytag: member="MACAddress::address" ref="a0c29ad39890488e0f7bc4ee20624e04e" args="" -->
uint64&#160;</td><td class="memItemRight" valign="bottom"><b>address</b></td></tr>
<tr><td colspan="2"><h2><a name="pri-static-attribs"></a>
Static Private Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a061dad67b44a20a397f0ea3b23666747"></a><!-- doxytag: member="MACAddress::autoAddressCtr" ref="a061dad67b44a20a397f0ea3b23666747" args="" -->
static unsigned int&#160;</td><td class="memItemRight" valign="bottom"><b>autoAddressCtr</b></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Stores an IEEE 802 MAC address (6 octets = 48 bits). </p>
</div><hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a155b01d9d9c04fbe13ea9b821519b571"></a><!-- doxytag: member="MACAddress::MACAddress" ref="a155b01d9d9c04fbe13ea9b821519b571" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">MACAddress::MACAddress </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Default constructor initializes address bytes to zero. </p>
<div class="fragment"><pre class="fragment">{ address = 0; }
</pre></div>
</div>
</div>
<a class="anchor" id="acd5a34c4730c3ce448d9d727bb693827"></a><!-- doxytag: member="MACAddress::MACAddress" ref="acd5a34c4730c3ce448d9d727bb693827" args="(uint64 bits)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">MACAddress::MACAddress </td>
          <td>(</td>
          <td class="paramtype">uint64&#160;</td>
          <td class="paramname"><em>bits</em></td><td>)</td>
          <td><code> [inline, explicit]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Initializes the address from the lower 48 bits of the 64-bit argument </p>
<div class="fragment"><pre class="fragment">{ address = bits &amp; MAC_ADDRESS_MASK; }
</pre></div>
</div>
</div>
<a class="anchor" id="a46d88d3231c166f8f6305e181e62a02e"></a><!-- doxytag: member="MACAddress::MACAddress" ref="a46d88d3231c166f8f6305e181e62a02e" args="(const char *hexstr)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">MACAddress::MACAddress </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>hexstr</em></td><td>)</td>
          <td><code> [inline, explicit]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Constructor which accepts a hex string (12 hex digits, may also contain spaces, hyphens and colons) </p>
<div class="fragment"><pre class="fragment">{ <a class="code" href="a00130.html#a8098d36b9f4a40ef61e1a3cb62cb27dd">setAddress</a>(hexstr); }
</pre></div>
</div>
</div>
<a class="anchor" id="a9ab1361f2773c6840f8fc96f73000b20"></a><!-- doxytag: member="MACAddress::MACAddress" ref="a9ab1361f2773c6840f8fc96f73000b20" args="(const MACAddress &amp;other)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">MACAddress::MACAddress </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="a00130.html">MACAddress</a> &amp;&#160;</td>
          <td class="paramname"><em>other</em></td><td>)</td>
          <td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Copy constructor. </p>
<div class="fragment"><pre class="fragment">{ address = other.address; }
</pre></div>
</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a606bb3ec3982d81913c464c18f34db6f"></a><!-- doxytag: member="MACAddress::compareTo" ref="a606bb3ec3982d81913c464c18f34db6f" args="(const MACAddress &amp;other) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int MACAddress::compareTo </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="a00130.html">MACAddress</a> &amp;&#160;</td>
          <td class="paramname"><em>other</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns -1, 0 or 1 as result of comparison of 2 addresses. </p>
<div class="fragment"><pre class="fragment">{
    <span class="keywordflow">return</span> (address &lt; other.address) ? -1 : (address == other.address) ? 0 : 1;  <span class="comment">// note: &quot;return address-other.address&quot; is not OK because 64-bit result does not fit into the return type</span>
}
</pre></div>
</div>
</div>
<a class="anchor" id="a2d1669ce517436105cd75faed677a303"></a><!-- doxytag: member="MACAddress::equals" ref="a2d1669ce517436105cd75faed677a303" args="(const MACAddress &amp;other) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool MACAddress::equals </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="a00130.html">MACAddress</a> &amp;&#160;</td>
          <td class="paramname"><em>other</em></td><td>)</td>
          <td> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns true if the two addresses are equal. </p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> address == other.address; }
</pre></div>
</div>
</div>
<a class="anchor" id="af646c7d6a3dbe4a94465fd3ec144f08f"></a><!-- doxytag: member="MACAddress::formInterfaceIdentifier" ref="af646c7d6a3dbe4a94465fd3ec144f08f" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="a00108.html">InterfaceToken</a> MACAddress::formInterfaceIdentifier </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Create interface identifier (IEEE EUI-64) which can be used by IPv6 stateless address autoconfiguration. </p>
<div class="fragment"><pre class="fragment">{
    uint32 high = ((address&gt;&gt;16)|0xff)^0x02000000;
    uint32 low = (0xfe&lt;&lt;24)|(address&amp;0xffffff);
    <span class="keywordflow">return</span> <a class="code" href="a00108.html">InterfaceToken</a>(low, high, 64);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a020d8e71aa50506e2b29a15833fedfd9"></a><!-- doxytag: member="MACAddress::generateAutoAddress" ref="a020d8e71aa50506e2b29a15833fedfd9" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="a00130.html">MACAddress</a> MACAddress::generateAutoAddress </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Generates a unique address which begins with 0a:aa and ends in a unique suffix. </p>
<div class="fragment"><pre class="fragment">{
    ++autoAddressCtr;

    uint64 intAddr = 0x0AAA00000000L + (autoAddressCtr &amp; 0xffffffffL);
    <a class="code" href="a00130.html">MACAddress</a> addr(intAddr);
    <span class="keywordflow">return</span> addr;
}
</pre></div>
</div>
</div>
<a class="anchor" id="ac6db3e8b6dd37f0a93d89367fefb9d27"></a><!-- doxytag: member="MACAddress::getAddressByte" ref="ac6db3e8b6dd37f0a93d89367fefb9d27" args="(unsigned int k) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned char MACAddress::getAddressByte </td>
          <td>(</td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>k</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns the kth byte of the address. </p>

<p>Referenced by <a class="el" href="a00130.html#aecea3ba50c9d01ec71c7bde14c71a9e4">getAddressBytes()</a>, and <a class="el" href="a00130.html#a5eed6450abcdd795b2a3d59828a29802">str()</a>.</p>
<div class="fragment"><pre class="fragment">{
    <span class="keywordflow">if</span> (k&gt;=MAC_ADDRESS_SIZE) <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;Array of size 6 indexed with %d&quot;</span>, k);
    <span class="keywordtype">int</span> offset = (MAC_ADDRESS_SIZE-k-1)*8;
    <span class="keywordflow">return</span> 0xff&amp;(address&gt;&gt;offset);
}
</pre></div>
</div>
</div>
<a class="anchor" id="aecea3ba50c9d01ec71c7bde14c71a9e4"></a><!-- doxytag: member="MACAddress::getAddressBytes" ref="aecea3ba50c9d01ec71c7bde14c71a9e4" args="(unsigned char *addrbytes) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void MACAddress::getAddressBytes </td>
          <td>(</td>
          <td class="paramtype">unsigned char *&#160;</td>
          <td class="paramname"><em>addrbytes</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Copies the address to the given pointer (array of 6 unsigned chars). </p>

<p>References <a class="el" href="a00130.html#ac6db3e8b6dd37f0a93d89367fefb9d27">getAddressByte()</a>.</p>
<div class="fragment"><pre class="fragment">{
    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; MAC_ADDRESS_SIZE; i++)
        addrbytes[i] = <a class="code" href="a00130.html#ac6db3e8b6dd37f0a93d89367fefb9d27">getAddressByte</a>(i);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a5f94a6533e6b7854c43c0a562622156a"></a><!-- doxytag: member="MACAddress::getAddressSize" ref="a5f94a6533e6b7854c43c0a562622156a" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned int MACAddress::getAddressSize </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns the address size in bytes, that is, 6. </p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> MAC_ADDRESS_SIZE; }
</pre></div>
</div>
</div>
<a class="anchor" id="a79f00509111e457048de0d6f5ae7aede"></a><!-- doxytag: member="MACAddress::getInt" ref="a79f00509111e457048de0d6f5ae7aede" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint64 MACAddress::getInt </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Converts address to 48 bits integer. </p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> address; }
</pre></div>
</div>
</div>
<a class="anchor" id="aa65a288ef8fe0e08e66912ffda5e3706"></a><!-- doxytag: member="MACAddress::isBroadcast" ref="aa65a288ef8fe0e08e66912ffda5e3706" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool MACAddress::isBroadcast </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns true if this is the broadcast address (hex ff:ff:ff:ff:ff:ff). </p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> address == MAC_ADDRESS_MASK; }
</pre></div>
</div>
</div>
<a class="anchor" id="aec80ce7ee8f529716e4b9354e93ca3c0"></a><!-- doxytag: member="MACAddress::isMulticast" ref="aec80ce7ee8f529716e4b9354e93ca3c0" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool MACAddress::isMulticast </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns true if this is a multicast logical address (first byte's lsb is 1). </p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> <a class="code" href="a00130.html#ac6db3e8b6dd37f0a93d89367fefb9d27">getAddressByte</a>(0) &amp; 0x01; };
</pre></div>
</div>
</div>
<a class="anchor" id="ae41af013d782b46483e7d0c84f0ed107"></a><!-- doxytag: member="MACAddress::isUnspecified" ref="ae41af013d782b46483e7d0c84f0ed107" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool MACAddress::isUnspecified </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns true if all address bytes are zero. </p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> address == 0; }
</pre></div>
</div>
</div>
<a class="anchor" id="a931bca85d72f853c0a5bda55edd85365"></a><!-- doxytag: member="MACAddress::operator!=" ref="a931bca85d72f853c0a5bda55edd85365" args="(const MACAddress &amp;other) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool MACAddress::operator!= </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="a00130.html">MACAddress</a> &amp;&#160;</td>
          <td class="paramname"><em>other</em></td><td>)</td>
          <td> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns true if the two addresses are not equal. </p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> address != other.address; }
</pre></div>
</div>
</div>
<a class="anchor" id="a81e0e779bcc372284a137c141eb14f3d"></a><!-- doxytag: member="MACAddress::operator=" ref="a81e0e779bcc372284a137c141eb14f3d" args="(const MACAddress &amp;other)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="a00130.html">MACAddress</a>&amp; MACAddress::operator= </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="a00130.html">MACAddress</a> &amp;&#160;</td>
          <td class="paramname"><em>other</em></td><td>)</td>
          <td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Assignment. </p>
<div class="fragment"><pre class="fragment">{ address = other.address; <span class="keywordflow">return</span> *<span class="keyword">this</span>; }
</pre></div>
</div>
</div>
<a class="anchor" id="af52a8fbbad1c1d4fa4c4c4689911698d"></a><!-- doxytag: member="MACAddress::operator==" ref="af52a8fbbad1c1d4fa4c4c4689911698d" args="(const MACAddress &amp;other) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool MACAddress::operator== </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="a00130.html">MACAddress</a> &amp;&#160;</td>
          <td class="paramname"><em>other</em></td><td>)</td>
          <td> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns true if the two addresses are equal. </p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> address == other.address; }
</pre></div>
</div>
</div>
<a class="anchor" id="a8098d36b9f4a40ef61e1a3cb62cb27dd"></a><!-- doxytag: member="MACAddress::setAddress" ref="a8098d36b9f4a40ef61e1a3cb62cb27dd" args="(const char *hexstr)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void MACAddress::setAddress </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>hexstr</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Converts address value from hex string (12 hex digits, may also contain spaces, hyphens and colons) </p>

<p>References <a class="el" href="a00130.html#a4e4d6d6314b17e0b7c76356db6b7e794">tryParse()</a>.</p>
<div class="fragment"><pre class="fragment">{
    <span class="keywordflow">if</span> (!<a class="code" href="a00130.html#a4e4d6d6314b17e0b7c76356db6b7e794">tryParse</a>(hexstr))
        <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;MACAddress: wrong address syntax &#39;%s&#39;: 12 hex digits expected, with optional embedded spaces, hyphens or colons&quot;</span>, hexstr);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a58b9995961b675dc92e06e769c01565c"></a><!-- doxytag: member="MACAddress::setAddressByte" ref="a58b9995961b675dc92e06e769c01565c" args="(unsigned int k, unsigned char addrbyte)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void MACAddress::setAddressByte </td>
          <td>(</td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>k</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&#160;</td>
          <td class="paramname"><em>addrbyte</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Sets the kth byte of the address. </p>

<p>Referenced by <a class="el" href="a00130.html#a6804ca5591fc6eeb256cc487805a0927">setAddressBytes()</a>, and <a class="el" href="a00130.html#a4e4d6d6314b17e0b7c76356db6b7e794">tryParse()</a>.</p>
<div class="fragment"><pre class="fragment">{
    <span class="keywordflow">if</span> (k&gt;=MAC_ADDRESS_SIZE) <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;Array of size 6 indexed with %d&quot;</span>, k);
    <span class="keywordtype">int</span> offset = (MAC_ADDRESS_SIZE-k-1)*8;
    address = (address&amp;(~(((uint64)0xff)&lt;&lt;offset)))|(((uint64)addrbyte)&lt;&lt;offset);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a6804ca5591fc6eeb256cc487805a0927"></a><!-- doxytag: member="MACAddress::setAddressBytes" ref="a6804ca5591fc6eeb256cc487805a0927" args="(unsigned char *addrbytes)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void MACAddress::setAddressBytes </td>
          <td>(</td>
          <td class="paramtype">unsigned char *&#160;</td>
          <td class="paramname"><em>addrbytes</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Sets address bytes. The argument should point to an array of 6 unsigned chars. </p>

<p>References <a class="el" href="a00130.html#a58b9995961b675dc92e06e769c01565c">setAddressByte()</a>.</p>
<div class="fragment"><pre class="fragment">{
    address = 0; <span class="comment">// clear top 16 bits too that setAddressByte() calls skip</span>
    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; MAC_ADDRESS_SIZE; i++)
        <a class="code" href="a00130.html#a58b9995961b675dc92e06e769c01565c">setAddressByte</a>(i, addrbytes[i]);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a38c4ea471051c76e593f2c6b0340b1fe"></a><!-- doxytag: member="MACAddress::setBroadcast" ref="a38c4ea471051c76e593f2c6b0340b1fe" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void MACAddress::setBroadcast </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Sets the address to the broadcast address (hex ff:ff:ff:ff:ff:ff). </p>
<div class="fragment"><pre class="fragment">{ address = MAC_ADDRESS_MASK; }
</pre></div>
</div>
</div>
<a class="anchor" id="a5eed6450abcdd795b2a3d59828a29802"></a><!-- doxytag: member="MACAddress::str" ref="a5eed6450abcdd795b2a3d59828a29802" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">std::string MACAddress::str </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Converts address to a hex string. </p>

<p>References <a class="el" href="a00130.html#ac6db3e8b6dd37f0a93d89367fefb9d27">getAddressByte()</a>.</p>
<div class="fragment"><pre class="fragment">{
    <span class="keywordtype">char</span> buf[20];
    <span class="keywordtype">char</span> *s = buf;
    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;MAC_ADDRESS_SIZE; i++, s += 3)
        sprintf(s, <span class="stringliteral">&quot;%2.2X-&quot;</span>, <a class="code" href="a00130.html#ac6db3e8b6dd37f0a93d89367fefb9d27">getAddressByte</a>(i));
    *(s-1) = <span class="charliteral">&#39;\0&#39;</span>;
    <span class="keywordflow">return</span> std::string(buf);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a4e4d6d6314b17e0b7c76356db6b7e794"></a><!-- doxytag: member="MACAddress::tryParse" ref="a4e4d6d6314b17e0b7c76356db6b7e794" args="(const char *hexstr)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool MACAddress::tryParse </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>hexstr</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Sets the address and returns true if the syntax of the string is correct. (See <a class="el" href="a00130.html#a8098d36b9f4a40ef61e1a3cb62cb27dd">setAddress()</a> for the syntax.) </p>

<p>References <a class="el" href="a00130.html#a58b9995961b675dc92e06e769c01565c">setAddressByte()</a>.</p>

<p>Referenced by <a class="el" href="a00130.html#a8098d36b9f4a40ef61e1a3cb62cb27dd">setAddress()</a>.</p>
<div class="fragment"><pre class="fragment">{
    <span class="keywordflow">if</span> (!hexstr)
        <span class="keywordflow">return</span> <span class="keyword">false</span>;

    <span class="comment">// check syntax</span>
    <span class="keywordtype">int</span> numHexDigits = 0;
    <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keywordtype">char</span> *s = hexstr; *s; s++) {
        <span class="keywordflow">if</span> (isxdigit(*s))
            numHexDigits++;
        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (*s!=<span class="charliteral">&#39; &#39;</span> &amp;&amp; *s!=<span class="charliteral">&#39;:&#39;</span> &amp;&amp; *s!=<span class="charliteral">&#39;-&#39;</span>)
            <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">// wrong syntax</span>
    }
    <span class="keywordflow">if</span> (numHexDigits != 2*MAC_ADDRESS_SIZE)
        <span class="keywordflow">return</span> <span class="keyword">false</span>;

    <span class="comment">// Converts hex string into the address</span>
    <span class="comment">// if hext string is shorter, address is filled with zeros;</span>
    <span class="comment">// Non-hex characters are discarded before conversion.</span>
    address = 0; <span class="comment">// clear top 16 bits too that setAddressByte() calls skip</span>
    <span class="keywordtype">int</span> k = 0;
    <span class="keyword">const</span> <span class="keywordtype">char</span> *s = hexstr;
    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> pos=0; pos&lt;MAC_ADDRESS_SIZE; pos++)
    {
        <span class="keywordflow">if</span> (!s || !*s)
        {
            <a class="code" href="a00130.html#a58b9995961b675dc92e06e769c01565c">setAddressByte</a>(pos, 0);
        }
        <span class="keywordflow">else</span>
        {
            <span class="keywordflow">while</span> (*s &amp;&amp; !isxdigit(*s)) s++;
            <span class="keywordflow">if</span> (!*s) {<a class="code" href="a00130.html#a58b9995961b675dc92e06e769c01565c">setAddressByte</a>(pos, 0); <span class="keywordflow">continue</span>;}
            <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> d = isdigit(*s) ? (*s-<span class="charliteral">&#39;0&#39;</span>) : islower(*s) ? (*s-<span class="charliteral">&#39;a&#39;</span>+10) : (*s-<span class="charliteral">&#39;A&#39;</span>+10);
            d = d&lt;&lt;4;
            s++;

            <span class="keywordflow">while</span> (*s &amp;&amp; !isxdigit(*s)) s++;
            <span class="keywordflow">if</span> (!*s) {<a class="code" href="a00130.html#a58b9995961b675dc92e06e769c01565c">setAddressByte</a>(pos, 0); <span class="keywordflow">continue</span>;}
            d += isdigit(*s) ? (*s-<span class="charliteral">&#39;0&#39;</span>) : islower(*s) ? (*s-<span class="charliteral">&#39;a&#39;</span>+10) : (*s-<span class="charliteral">&#39;A&#39;</span>+10);
            s++;

            <a class="code" href="a00130.html#a58b9995961b675dc92e06e769c01565c">setAddressByte</a>(pos, d);
            k++;
        }
    }
    <span class="keywordflow">return</span> <span class="keyword">true</span>;
}
</pre></div>
</div>
</div>
<hr/><h2>Member Data Documentation</h2>
<a class="anchor" id="a64288e3935e32fec17884c040cf2d2e9"></a><!-- doxytag: member="MACAddress::BROADCAST_ADDRESS" ref="a64288e3935e32fec17884c040cf2d2e9" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const <a class="el" href="a00130.html">MACAddress</a> <a class="el" href="a00130.html#a64288e3935e32fec17884c040cf2d2e9">MACAddress::BROADCAST_ADDRESS</a><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>The broadcast MAC address, ff:ff:ff:ff:ff:ff </p>

</div>
</div>
<a class="anchor" id="ad7361315e8e61b3e5e1494c55cc4721f"></a><!-- doxytag: member="MACAddress::MULTICAST_PAUSE_ADDRESS" ref="ad7361315e8e61b3e5e1494c55cc4721f" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const <a class="el" href="a00130.html">MACAddress</a> <a class="el" href="a00130.html#ad7361315e8e61b3e5e1494c55cc4721f">MACAddress::MULTICAST_PAUSE_ADDRESS</a><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>The special multicast PAUSE MAC address, 01:80:C2:00:00:01 </p>

</div>
</div>
<a class="anchor" id="a9083fdb636ab09f77e7af806f2d471b6"></a><!-- doxytag: member="MACAddress::UNSPECIFIED_ADDRESS" ref="a9083fdb636ab09f77e7af806f2d471b6" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const <a class="el" href="a00130.html">MACAddress</a> <a class="el" href="a00130.html#a9083fdb636ab09f77e7af806f2d471b6">MACAddress::UNSPECIFIED_ADDRESS</a><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>The unspecified MAC address, 00:00:00:00:00:00 </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/src/inet_stub/linklayer/contract/<a class="el" href="a00332_source.html">MACAddress.h</a></li>
<li>D:/Projects/MiXiM/extsrc/mixim/src/inet_stub/linklayer/contract/MACAddress.cc</li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00130.html">MACAddress</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:32 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
